package com.hy.appium1;

import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;

public class AppiumDemo1StartActivity {

    AndroidDriver driver;


    @BeforeMethod
    public void SetUp() throws MalformedURLException {
        //1.需要创建配置对象   desiredcapabilities
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        //将需要启动的软件的一些配置添加进来
        //1.添加需要测试 的主机的路径
        desiredCapabilities.setCapability("deviceName", "127.0.0.1:62001");
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("appPackage", "com.handsgo.jiakao.android");
        //默认启动不初始化软件
        desiredCapabilities.setCapability("noReset", "true");
        desiredCapabilities.setCapability("appActivity", "com.handsgo.jiakao.android.splash.Login");
        //创建驱动
//        AndroidDriver<WebElement> Driver = new AndroidDriver<WebElement>(url, desiredCapabilities);
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities);


    }

    @Test
    public void test() throws InterruptedException {

        Thread.sleep(25000);

        //实例化Activity，实现页面跳转

        Activity activity = new Activity("com.handsgo.jiakao.android", "cn.mucang.android.account.activity.LoginMultiDefaultSmsActivity");

        Thread.sleep(15000);


        driver.startActivity(activity);



    }

    @AfterMethod
    public void TestDown() {
//        driver.quit();
    }
}
